package com.jbp.controller;

import com.jbp.model.BlackDevice;
import com.jbp.service.BlackDeviceService;
import com.jbp.utils.PageUtils;
import com.jbp.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 设备黑名单(BlackDevice)表控制层
 * @author cc
 * @since 2020-11-06 13:59:23
 */
@Api(tags ="APP接口--BlackDevice" )
@RestController
@ApiIgnore
@RequestMapping("blackDevice")
public class BlackDeviceController {
    @Autowired
    private BlackDeviceService blackDeviceService;

    /** 列表 */
    @ApiOperation(value="列表")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = BlackDevice.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = blackDeviceService.queryPage(params);
        return R.ok().put("page", page);
    }
    
    @ApiOperation(value="信息")
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
        return R.ok(blackDeviceService.getById(id) );
    }
    
    /** 保存 */
    @RequestMapping("/save")
    public R save(@RequestBody BlackDevice blackDevice){
        blackDeviceService.save(blackDevice);
        return R.ok();
    }

    /** 修改 */
    @RequestMapping("/update")
    public R update(@RequestBody BlackDevice blackDevice){
        blackDeviceService.updateById(blackDevice);
        return R.ok();
    }

    /** 删除 */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        blackDeviceService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
}